package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo6 {
    public static void main(String[] args) {
        try (
                Connection conn = DBUtil.getConnection();
        ) {
            Statement statement = conn.createStatement();
            String str = "SELECT COUNT(*) count " +
                    "FROM student s " +
                    "JOIN class c ON c.id=s.class_id " +
                    "WHERE c.name = '1年级1班'";
            ResultSet rs =  statement.executeQuery(str);
            while(rs.next()){
                int count =rs.getInt("count");
                System.out.println("人数:"+count);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
